import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'
import mitt from 'mitt'
import Loading from './components/loading'

const Mit = mitt()

import './assets/main.css'

const app = createApp(App)

app.use(createPinia())
app.use(router)
app.use(Loading)

// typescript注册
// 由于必须要扩展的ComponentCustomProperties类型才能获得类型提示
declare module 'vue' {
    export interface ComponentCustomProperties {
        $Bus: typeof Mit
    }
}

type bglod = {
    show: (el?:HTMLElement) => void,
    hide: () => void
} 

declare module '@vue/runtime-core' {
    export interface ComponentCustomProperties {
        $bgLoading: bglod
    }
}

// 将mitt挂在到全局
app.config.globalProperties.$Bus = Mit

app.mount('#app')
